package org.ainlolcat.ainscience2.controller.loader.impl;

import org.ainlolcat.ainscience2.controller.loader.Loader;
import org.ainlolcat.ainscience2.controller.loader.LoaderDefinition;
import org.ainlolcat.ainscience2.model.Project;
import org.ainlolcat.ainscience2.model.filter.FilterApplier;
import org.ainlolcat.ainscience2.model.filter.impl.ElementNameAttrFilter;
import org.jdom.Element;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: ain
 * Date: 17.06.12
 * Time: 2:45
 * To change this template use File | Settings | File Templates.
 */
public class FileLoader implements Loader {
    LoaderDefinition definition;
    boolean recursively = false;
    String filename;
    String filenameRE;
    String delimiter = ";\t";
    
    public void setDefinition(LoaderDefinition definition) {
        this.definition = definition;
    }

    public void load(Project project) {
        List<Element> parameters = definition.getParameters().getChildren();

        Element rec = new FilterApplier().apply(
                parameters,
                new ElementNameAttrFilter(FileLoaderMetaData.PAR_RECURSIVELY)).iterator().next();
        recursively = rec==null?recursively:Boolean.parseBoolean(rec.getAttributeValue("value"));
    }

    public String extractParameter(){
        return null;
    }
}
